﻿#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

//给定一个整数数组 nums 和一个整数目标值 target
//请你在该数组中找出 和为目标值target的那两个整数
//并返回它们的数组下标

//返回两个值可以使用指针
int* twoSum(int* nums, int sz, int target,int *res) {
    int i = 0;
    int j = 0;
    //int* res = (int*)malloc(sizeof(int) * 2);
    for (i = 0; i < sz - 1; i++) {
        for (j = i + 1; j < sz; j++) {
            if (*(nums + i) + *(nums + j) == target) {
                res[0] = i;
                res[1] = j;
                return res;
            }
        }
    }
    return res;
}
int main() {
    int arr[] = { 2,3,4,5,6,1,13,26 };
    int target = 14;
    int sz = sizeof(arr) / sizeof(arr[0]);
    int res[2] = { 0 };
    int* ret = twoSum(arr,sz,target,res);
    printf("%d %d", *(ret), *(ret + 1));
	return 0;
}

